package com.tql.mall.boss.controller.boss;

import com.tql.mall.boss.service.BaseCategoryViewService;
import com.tql.mall.common.result.R;
import com.tql.mall.model.product.BaseCategoryView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "总体商品分类接口")
@RestController
@RequestMapping("/boss/boss/classify")
public class ClassifyController {

    @Autowired
    private BaseCategoryViewService baseCategoryViewService;



    /**
     * 根据三级分类的 id，获取BaseCategoryView对象
     * @param id
     * @return
     */
    @ApiOperation("根据三级分类的 id，获取BaseCategoryView对象")
    @GetMapping("/getCategoryView/{id}")
    public R<BaseCategoryView> getCategoryView(@PathVariable Long id){
        BaseCategoryView baseCategoryView = baseCategoryViewService.getCategoryView(id);
        if (baseCategoryView != null) return R.ok(baseCategoryView);
        return R.fail();
    }

    @ApiOperation("根据二级分类的 id，获取BaseCategoryView对象")
    @GetMapping("/getCategoryViewById2/{id}")
    public R<BaseCategoryView> getCategoryViewById2(@PathVariable Long id){
        BaseCategoryView baseCategoryView = baseCategoryViewService.getCategoryViewById2(id);
        if (baseCategoryView != null) return R.ok(baseCategoryView);
        return R.fail();
    }


    @ApiOperation("根据一级分类的 id，获取BaseCategoryView对象")
    @GetMapping("/getCategoryViewById1/{id}")
    public R<BaseCategoryView> getCategoryViewById1(@PathVariable Long id){
        BaseCategoryView baseCategoryView = baseCategoryViewService.getCategoryViewById1(id);
        if (baseCategoryView != null) return R.ok(baseCategoryView);
        return R.fail();
    }










}
